package gold.digger;

import gold.utils.InputUtil;
import gold.vo.TreeNode;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC965 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public boolean isUnivalTree(TreeNode root) {
            int wholeVal = root.val;
            return isUnivalTreeRecur(root, wholeVal);
        }

        public boolean isUnivalTreeRecur(TreeNode root, int wholeVal) {
            if (null == root) return true;
            if (root.val != wholeVal) return false;
            return isUnivalTreeRecur(root.left, wholeVal) && isUnivalTreeRecur(root.right, wholeVal);
        }
    }

    public void run() {
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(new Solution().toString());
    }

    public static void main(String[] args) throws Exception {
        LC965 an = new LC965();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
